#ifndef GLOBAL_H_
#define GLOBAL_H_

#include <gdi.h>
#include <BADESCA.H>
#include <e32cmn.h>
#include <e32def.h>
#include <e32base.h>
#include "CImagePool.h"
#include "writablebitmap.h"

class UIControlEnv : public CBase
{
public:
	UIControlEnv();
	~UIControlEnv();

public:
	static TRect GetClientRect();
	static TDisplayMode GetDisplayMode();
	
	TBool ResolvePath(TDes& aPath) const;
	CWritableBitmap* HelperBitmap(TInt aIndex, const TSize& aSize) ;
	
	RFs& FsSession() const;
public:
	static UIControlEnv* NewL();
	static UIControlEnv* NewLC();
	
	void ConstructL();
	
public:
	static UIControlEnv* Static()
	{
		if(!iStatic)
			{
			iStatic = UIControlEnv::NewL();
			
			}
		
		return iStatic;
	}
	
	static void Release()
		{
		if(iStatic)
			delete iStatic;
		}
public:
	static UIControlEnv* iStatic;
	
public:
	CDesCArray* iSearchPaths;
	
private:
	CWritableBitmap* iHelperBitmap[3];
};

class UIControlUtil
{
public:
	static TUint32 StrToInt(const TDesC& aSource, TRadix aRadix=EDecimal);
	static TBool StrToBool(const TDesC& aSource);
	static void Trim(TPtrC& aDest);
	
	static HBufC* StringReplaceL(const TDesC& aSource, const TDesC& aTarget, const TDesC& aReplacement);
	static void StringReplace(const TDesC& aSource, const TDesC& aTarget, const TDesC& aReplacement, TDes& aDest);
	static void StringReplace(TDes& aTarget, TChar aSrcChar, TChar aDestChar);
	static TBool StringSplit(const TDesC& aSource, TInt& aOffset, TChar aSeperator, TPtrC& aRet);
	
	static void ParseHexColor(const TDesC& aSource, TRgb& aRgb);
	static void ParseColor(const TDesC& aSource, TRgb& aRgb);
};

class UIGlobalRelease
	{
public:
	static void Release()
		{
		UIControlEnv::Release();
		CImagePool::Release();
		}
	};
#endif /*GLOBAL_H_*/
